import { ajaxGet, ajaxPost } from '../utils/ajax'
import { COMMENT_DEL_URL, COMMENT_LIST_URL, COMMENT_UPDATE_URL, CREATE_COMMENT_URL } from '../conf/apis'

async function createCommentService(content = '') {
  return await ajaxPost(CREATE_COMMENT_URL, { content })
}

async function getCommentListService(filterType = 1) {
  return await ajaxGet(`${COMMENT_LIST_URL}?filterType=${filterType}`)
}

async function delCommentService(_id) {
  return await ajaxPost(COMMENT_DEL_URL, { _id })
}

async function updateCommentService(_id, content) {
  return await ajaxPost(COMMENT_UPDATE_URL, { _id, content })
}

export {
  createCommentService,
  getCommentListService,
  delCommentService,
  updateCommentService
}
